package leetcode.D500.T461;

class Solution {
    public int hammingDistance(int x, int y) {
        int result = 0, a = 0, b = 0, temp = 0;
        for(int i=30; i>=0; --i) {
            temp = 1 << i;
            if(x >= temp) {
                a = 1;
                x -= temp;
            } else {
                a = 0;
            }
            if(y >= temp) {
                b = 1;
                y -= temp;
            } else {
                b = 0;
            }
            if(a != b) {
                result++;
            }
            System.out.println(a + " " + b);
        }
        return result;
    }
}
